package com.wsz.security;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class controller {
    @GetMapping("/admin/info")
    public String getAdmin(){
        return "this admin";
    }


    @GetMapping("/root/info")
    public String getRoot(){
        return "this root";
    }

    @GetMapping("/info/getinfo")
    public String getInfo(){
        return "this info";
    }

    @PreAuthorize("hasRole('root') and authentication.name=='wsz'")
    @GetMapping("/name")
    public String name(){
        return "name";
    }


    @PreAuthorize("hasRole('root') and authentication.name==#name")
    @GetMapping("/name1")
    public String gethy(String name){
        return "hello"+name;
    }


}
